%#include <chord_types.h>
%#include <dhash_types.h>

typedef opaque incognito_value<>;

struct incognito_store_arg 
{
	dhash_ctype	key_type;
	bigint		key_value;
	incognito_value	data;
};

/* Fetch - begin */
struct incognito_fetch_arg
{
	dhash_ctype	key_type;
	bigint		key_value;
};
struct incognito_fetch_res
{

	incognito_value	data;
};
/* Fetch - end */


/* Diffie-Hellman - begin */
struct incognito_dh_arg
{
	chordID		caller_ID;
	bigint		p;
	bigint		g;
	bigint		caller_pubkey;
};

struct incognito_dh_res
{
	bigint		callee_pubkey;
};
/* Diffie-Hellman - end */

/* FIXME: Obsolete */
struct incognito_enc_store_arg
{
	chordID		caller_ID;
	unsigned int	seq_num;
	incognito_value	enc_data;
};

/* Argument and result of INCOGNITOPROC_ENC_MESSAGE */
struct incognito_encrypted_request
{
	chordID		caller_ID;	// ID of message's sender
	unsigned int	seq_num;
	incognito_value	enc_data;
};
/* Structure passed inside incognito_encrypted_request.enc_data */
struct incognito_raw_request
{
	unsigned int	request_type;	// 0 - store req, 1 - store resp, 2 - fetch req, 3 - fetch resp, 4 - generic error
	unsigned int	status;		// Used in: store resp, fetch resp
	dhash_ctype	key_type;	// Used in: store req, fetch req
	bigint		key_value;	// Used in: store req, fetch req
	incognito_value	data;		// Used in: store req, fetch resp
};

program INCOGNITO_PROGRAM {
  version INCOGNITO_VERSION {
    void
    INCOGNITOPROC_NULL (void) = 0;

    void
    INCOGNITOPROC_STORE (incognito_store_arg) = 1;

    incognito_fetch_res
    INCOGNITOPROC_FETCH (incognito_fetch_arg) = 2;		/* FIXME: Obsolete */

    incognito_dh_res
    INCOGNITOPROC_DHKEY_EXCHANGE (incognito_dh_arg) = 3;

    void
    INCOGNITOPROC_ENC_STORE(incognito_enc_store_arg) = 4;	/* FIXME: Obsolete */

    incognito_fetch_res
    INCOGNITOPROC_FETCH_ANONYMOUSLY (incognito_fetch_arg) = 5;
    
    incognito_encrypted_request
    INCOGNITOPROC_ENC_MESSAGE(incognito_encrypted_request) = 6; /* Generic encrypted call. Should replace INCOGNITO_ENC_STORE */

  } = 1;
} = 344444;
